import java.util.HashMap;
import java.util.Map;

// 学生关系类型枚举
enum RelationshipType {
    CLASSMATE, ROOMMATE, FRIEND, TEAM_MEMBER
}

// 学生关系系统类，管理学生之间的关系
public class StudentRelationshipSystem {
    // 使用邻接表表示学生关系图
    private Map<Integer, Map<Integer, RelationshipType>> relationships = new HashMap<>();

    // 添加学生到关系图中（当添加新学生时调用）
    public void addStudent(int studentId) {
        if (!relationships.containsKey(studentId)) {
            relationships.put(studentId, new HashMap<>());
        }
    }

    // 删除学生从关系图中
    public void removeStudent(int studentId) {
        // 移除该学生的所有关系
        relationships.remove(studentId);
        
        // 从其他学生的关系中移除该学生
        for (Map<Integer, RelationshipType> relationMap : relationships.values()) {
            relationMap.remove(studentId);
        }
    }

    // 添加学生关系
    public void addRelationship(int studentId1, int studentId2, RelationshipType type) {
        // 确保两个学生都在关系图中
        if (!relationships.containsKey(studentId1) || !relationships.containsKey(studentId2)) {
            throw new IllegalArgumentException("One or both students not found in the system");
        }
        
        // 添加双向关系
        relationships.get(studentId1).put(studentId2, type);
        relationships.get(studentId2).put(studentId1, type);
    }

    // 移除学生关系
    public void removeRelationship(int studentId1, int studentId2) {
        // 移除双向关系
        if (relationships.containsKey(studentId1)) {
            relationships.get(studentId1).remove(studentId2);
        }
        if (relationships.containsKey(studentId2)) {
            relationships.get(studentId2).remove(studentId1);
        }
    }

    // 查询某个学生的所有关系
    public Map<Integer, RelationshipType> getRelationships(int studentId) {
        if (relationships.containsKey(studentId)) {
            return new HashMap<>(relationships.get(studentId));
        }
        return new HashMap<>();
    }

    // 查询两个学生之间的特定关系
    public RelationshipType getRelationshipBetweenStudents(int studentId1, int studentId2) {
        if (relationships.containsKey(studentId1) && relationships.get(studentId1).containsKey(studentId2)) {
            return relationships.get(studentId1).get(studentId2);
        }
        return null;
    }
}